Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> xml->childNodes
ljmedia
post
Post #1





Grupa: Zarejestrowani
Postów: 3
Pomógł: 0
Dołączył: 18.04.2005

Ostrzeżenie: (0%)
-----


witam forumowiczów

czy jest jakas funkcja zracająca ilosc węzłów w pliku xml np :
  1. <root>
  2. <wezel />
  3. <wezel />
  4. .......
  5. <wezel />
  6. </root>


i teraz aby wyciągnąć ilość wystąpienia <wezel /> ( nie moge znaleźc takiej funkcji sad.gif )
moze smiesznie porównam ale we flashu robie poprostu

var ile = root.firstChild.childNodes.length i mam ilosc smile.gif , gdzie root jest obiektem XML

pozdrawiam ljmedia
Go to the top of the page
+Quote Post
dasko
post
Post #2





Grupa: Zarejestrowani
Postów: 179
Pomógł: 0
Dołączył: 9.11.2004

Ostrzeżenie: (0%)
-----


Tutaj powinno też takie cuś działać:
Kod
var xml = document.implementation.createDocument("", "", null);
xml.load('jakistamplik.xml');
var ile = xml.documentElement.childNodes.length; // ilosc

biggrin.gif
Go to the top of the page
+Quote Post
ljmedia
post
Post #3





Grupa: Zarejestrowani
Postów: 3
Pomógł: 0
Dołączył: 18.04.2005

Ostrzeżenie: (0%)
-----


hmm nie bardzo mi to działa sad.gif a php-ie nie jestem zbyt biegły.

ljmedia
Go to the top of the page
+Quote Post
dasko
post
Post #4





Grupa: Zarejestrowani
Postów: 179
Pomógł: 0
Dołączył: 9.11.2004

Ostrzeżenie: (0%)
-----


Heh, sorry :] ja myślałem, że chodzi ci o JavaScript biggrin.gif w php będzie podobnie:
  1. <?php
  2.  
  3. $xml = new DOMDocument; // nowy dokument
  4. $xml->load('jakisTamPlik.xml'); // ladujemy plik
  5. $ile = $xml->getElementsByTagName('wezel'); // wszystkie węzły 'wezel'
  6. $ile = $ile->length; // ilosc wezlow w dokumencie
  7.  
  8. ?>

Jakby co: http://www.php.net/manual/en/ref.dom.php -> tam wszystko jest smile.gif

Ten post edytował dasko 19.04.2005, 13:31:07
Go to the top of the page
+Quote Post
ljmedia
post
Post #5





Grupa: Zarejestrowani
Postów: 3
Pomógł: 0
Dołączył: 18.04.2005

Ostrzeżenie: (0%)
-----


wielkie dzieki smile.gif
Pozdrawiam ljmedia
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 19.08.2025 - 15:18